//
//  CertifyConditionViewModel.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/6/25.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

class CertifyConditionViewModel: BaseViewModel {
    @objc dynamic  var refreshBool = false //监听的状态
    var isSuccess = false //判断是否认证成功 true  认证中 false
    var model:CertificationStatesModel = CertificationStatesModel()
    lazy var identyRequest:IdentyInforRequest = {
        let api = IdentyInforRequest()
        api.dataReformer = self
        api.paramSource = self
        api.delegate = self
        return api
    }()
    
    func archiveInformation() {
        self.request(request: identyRequest, success: {[weak self] (result) in
            if result?["data"] as? [String : Any] == nil  {
                return
            }
            self?.model = CertificationStatesModel(JSON: result?["data"] as! [String : Any])!
            self?.refreshBool = true
            
        }) { (response) in
            
        }
    }
}
extension CertifyConditionViewModel:RequestCallBack,RequestDataReformer,RequestParamSource {
    func reform(_ request: BaseRequest, _ data: [String : Any]?) {
        if successBlock != nil {
            successBlock!(data)
        }
    }
    
    func requestDidSucess(_ request: BaseRequest) {
        
    }
    
    func requestDidFail(_ request: BaseRequest) {
        if failBlock != nil {
            failBlock!(request)
        }
    }
    
    func requestParams(_ request: BaseRequest) -> [String : Any]? {
        let pramas: [String:Any] = [:]
        if let _ = request as? IdentyRequest {
            
        }
        
        return pramas
    }
}
